_ut()
{
    local cur prev opts cmd modules
    COMPREPLY=()

    cur="${COMP_WORDS[COMP_CWORD]}"
    prev="${COMP_WORDS[COMP_CWORD-1]}"

    cmd="/usr/bin/ut"
    modules=`$cmd -m`

    if [[ COMP_CWORD -eq 1 ]]; then
        COMPREPLY=( $(compgen -W "${modules}" -- ${cur}) )
    elif [[ COMP_CWORD -eq 2 && $modules =~ $prev ]]; then
        if [[ -z $cur ]]; then
            cur=`$cmd -lt $prev`
            compopt -o nospace
            COMPREPLY=( $(compgen -W "$cur") )
        else
            compopt -o nospace -o default
        fi
    elif [[ COMP_CWORD -ge 3 ]]; then
        prev="${COMP_WORDS[COMP_CWORD-2]}"
        if [[ -z $cur ]]; then
            cur=`$cmd -lc $prev`
            compopt -o nospace
            COMPREPLY=( $(compgen -W "$cur") )
        else
            compopt -o nospace -o default
        fi
    fi
    return 0
}

complete -F _ut ut
